﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MyPlanSilverlight.Utils
{
    public class JsonUtils
    {
        public static T toEntity<T>(string jsonString) where T : new() 
        {
            T deserialized = JsonConvert.DeserializeObject<T>(jsonString);
            return deserialized;
        }

        public static List<T> toEntityList<T>(string jsonString) where T : new()
        {
            List<T> deserialized = JsonConvert.DeserializeObject<List<T>>(jsonString);
            return deserialized;
        }

        public static string toJson(object entity) 
        {
            return JsonConvert.SerializeObject(entity);
        }
    }
}
